//DefaultForwardFX.h
//Created 18/08/13
//Created By Daniel Bowler
//
//Class that represents my DefaultForward.fxo effect. A simple effect
//that supports (blinn-phong) lighting and texturing. 
//
//Primairly used as an education shader, but it may have additional uses
//(eg, a good shader for transparant objects in the final phase of the
//deferred renderer)

#pragma once

#include "AbstractFX.h"

class DefaultForwardFX : public AbstractFX
{
	//Ensure that the ShaderManager can access private functions - the constructor/
	//destructor. Thus, the ShaderManager will be the only class allowed to 
	//create/destroy Effects.
	friend ShaderManager;
public:
	//Per vertex structure.
	struct PosNormalTexVertex
	{
		XMFLOAT3 PosL;
		XMFLOAT3 NormalL;
		XMFLOAT2 Tex;
	};
	//Sets cbuffer data
	void SetCBufferPerObject(CXMMATRIX& world, 
		CXMMATRIX& worldInvTrans, CXMMATRIX& worldViewProj, CXMMATRIX& texTrans, Material& mat);

	//Set Texture Data
	void SetShaderResources(ID3D11ShaderResourceView* diffuseMap = NULL);

	//Sets lighting data
	void SetCBufferLighting(XMFLOAT3 eye, bool updateLights,
		DirectionalLight* dLights = NULL, unsigned dLightCount = 3,
		PointLight* pLights = NULL, unsigned pLightCount = 100, 
		SpotLight* sLights = NULL, unsigned sLightCount = 100);

private:
	DefaultForwardFX(ID3D11Device* device);
	~DefaultForwardFX();
	//Disable copy constrcutor and assignment operator
	DefaultForwardFX(DefaultForwardFX& copy);
	DefaultForwardFX& operator=(DefaultForwardFX& other);

	//Override the init methods.
	void InitInputLayout(ID3D11Device* device);
	void InitShaderVariablePointers();

private:
	//Variable pointers.
	//
	//Cbuffer Data:
	ID3DX11EffectMatrixVariable* worldVar;
	ID3DX11EffectMatrixVariable* worldInvTransVar;
	ID3DX11EffectMatrixVariable* worldViewProjVar;
	ID3DX11EffectMatrixVariable* texTransformVar;

	//Texture Data:
	ID3DX11EffectShaderResourceVariable* diffuseMapVar; //Texuture mapping.

	//Lighting data
	ID3DX11EffectVectorVariable* eyePosVar;
	ID3DX11EffectVariable* materialVar;

	ID3DX11EffectVariable* direcLightVar;
	ID3DX11EffectVariable* pointLightVar;
	ID3DX11EffectVariable* spotLightVar;
};